package company.meituan_F;

import java.util.*;

public class M3 {

    // 深度优先遍历
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer, Set<Integer>> dict = new TreeMap<>();
        for (int i = 0; i < m; i++) {
            int start = sc.nextInt();
            int end = sc.nextInt();
            int min = Math.min(start, end);
            int max = Math.max(start, end);
            Set<Integer> set = dict.getOrDefault(min, new HashSet<>());
            set.add(max);
            dict.put(min, set);
        }
        List<TreeSet<Integer>> result = new ArrayList<>();
        Set<Integer> used = new HashSet<>();
        for (Map.Entry<Integer, Set<Integer>> e : dict.entrySet()) {
            TreeSet<Integer> tmp = new TreeSet<>();
            Queue<Integer> queue = new ArrayDeque<>();
            queue.add(e.getKey());
            while (queue.size() != 0) {
                Integer poll = queue.poll();
                if (!used.contains(poll)) {
                    tmp.add(poll);
                    used.add(poll);
                    Set<Integer> set = dict.get(poll);
                    if (set != null)
                        for (Integer integer : set) {
                            if (!used.contains(integer)) {
                                queue.add(integer);
                            }
                        }
                }
            }
            if (!tmp.isEmpty())
                result.add(tmp);
        }
        System.out.println(result.size());
        for (Set<Integer> set : result) {
            StringBuffer sb = new StringBuffer();
            for (Integer i : set) {
                sb.append(i).append(" ");
            }
            System.out.println(sb);
        }
    }
}
